{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "13e1694f",
   "metadata": {},
   "source": [
    "# Python演示\n",
    "\n",
    "## 数学运算\n",
    "\n",
    "简单的数学运算："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0862cb62",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2 + 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "01efe954",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.5"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7 - 2.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b0e32437",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7.5"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 * 2.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3e6e4505",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "8 / 4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7bfc220c",
   "metadata": {},
   "source": [
    "## 赋值\n",
    "\n",
    "使用`变量名=表达式`赋值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cb13f987",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 0.2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19b510d6",
   "metadata": {},
   "source": [
    "## 字符串\n",
    "\n",
    "字符串生成，单引号与双引号是等价的："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2b934eaa",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = \"hello world\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "bf733779",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = 'hello world'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdeae80d",
   "metadata": {},
   "source": [
    "三引号用来输入包含多行文字的字符串："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "058792a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello\\nworld'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"hello\n",
    "world\"\"\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d845d076",
   "metadata": {},
   "source": [
    "字符串的加法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c6e43bc0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello world'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"hello\" + \" world\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1ec3be3",
   "metadata": {},
   "source": [
    "字符串索引："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c53075be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'h'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ae1eb479",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'d'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "7b5b91c7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[:5]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2e93d42",
   "metadata": {},
   "source": [
    "字符串的分割："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "60ecc68f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['hello', 'world']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.split()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36736930",
   "metadata": {},
   "source": [
    "字符串的长度："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8f42fafd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f026479",
   "metadata": {},
   "source": [
    "## 列表\n",
    "\n",
    "列表可以用中括号生成："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "179dfa56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2.0, 'hello', 6.0]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = [1, 2.0, 'hello', 5 + 1.0]\n",
    "a"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "667bac07",
   "metadata": {},
   "source": [
    "加法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "3dd5f339",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2.0, 'hello', 6.0, 1, 2.0, 'hello', 6.0]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + a"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1024c6ca",
   "metadata": {},
   "source": [
    "列表索引："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "84e54fbd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53f7d454",
   "metadata": {},
   "source": [
    "长度："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "966f6c89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3bb8297",
   "metadata": {},
   "source": [
    "添加元素："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "6e2b7795",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b3af4ea2",
   "metadata": {},
   "source": [
    "## 集合\n",
    "\n",
    "集合可以用花括号生成："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "dedd8f92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2, 3, 4}"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = {2, 3, 4, 2}\n",
    "s"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de4abb51",
   "metadata": {},
   "source": [
    "集合的长度："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "10a088e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5fd2ac17",
   "metadata": {},
   "source": [
    "向集合中添加元素："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "88ab84a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "s.add(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fd75bf0",
   "metadata": {},
   "source": [
    "集合的交："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "9834a201",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2, 3, 4}"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = {1, 2, 3, 4}\n",
    "b = {2, 3, 4, 5}\n",
    "a & b"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb1b0afc",
   "metadata": {},
   "source": [
    "并："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "871b3dd0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a | b"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5746f9f4",
   "metadata": {},
   "source": [
    "差："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "6f3d5afa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a - b"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5fff5d28",
   "metadata": {},
   "source": [
    "## 字典\n",
    "\n",
    "Python用{key:value}来生成字典："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "2f93efca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'dogs': 5, 'cats': 4}"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d = {'dogs':5, 'cats':4}\n",
    "d"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee8feeb1",
   "metadata": {},
   "source": [
    "大小："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "bdb41098",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(d)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd1720a1",
   "metadata": {},
   "source": [
    "查看字典某个键对应的值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "076bca20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d[\"dogs\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "066a4b49",
   "metadata": {},
   "source": [
    "修改键值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "75d8fe48",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'dogs': 2, 'cats': 4}"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d[\"dogs\"] = 2\n",
    "d"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "126f7d16",
   "metadata": {},
   "source": [
    "插入："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "e9c04d7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'dogs': 2, 'cats': 4, 'pigs': 7}"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d[\"pigs\"] = 7\n",
    "d"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05f47366",
   "metadata": {},
   "source": [
    "## NumPy数组\n",
    "\n",
    "很多高级的数学运算可以通过数组完成。首先需要导入NumPy："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "9b8c1b0c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "a = np.array([1, 2, 3, 4])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d5e6c12a",
   "metadata": {},
   "source": [
    "一些数学运算："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "baa3abc6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 4, 5, 6])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "ee40c17d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 4, 6, 8])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "479b113f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 4, 6, 8])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a * 2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ae1dd3b",
   "metadata": {},
   "source": [
    "## 可视化\n",
    "\n",
    "可以用Matplotlib对数据进行可视化："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "901a3e45",
   "metadata": {},
   "outputs": [],
   "source": [
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "05a12128",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x11250c460>]"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAA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with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(a, a**2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b3c7ad8d",
   "metadata": {},
   "source": [
    "## 循环\n",
    "\n",
    "可以使用`for`语句进行循环："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "a70257f3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1', '2', '3', '4', '5']"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "line = '1 2 3 4 5'\n",
    "fields = line.split()\n",
    "fields"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "b6ef72d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total = 0\n",
    "for field in fields:\n",
    "    total += int(field)\n",
    "total"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "075cc50d",
   "metadata": {},
   "source": [
    "列表推导式，用`for`循环生成列表："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "862a8878",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers = [int(field) for field in fields]\n",
    "numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "737ab850",
   "metadata": {},
   "source": [
    "## 文件操作\n",
    "\n",
    "写文件："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "b259797d",
   "metadata": {},
   "outputs": [],
   "source": [
    "f = open('data.txt', 'w')\n",
    "f.write('1 2 3 4\\n')\n",
    "f.write('2 3 4 5\\n')\n",
    "f.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "640c7aee",
   "metadata": {},
   "source": [
    "读文件："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "8f25a50a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 2, 3, 4], [2, 3, 4, 5]]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f = open('data.txt')\n",
    "data = []\n",
    "for line in f:\n",
    "    data.append([int(field) for field in line.split()])\n",
    "f.close()\n",
    "\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83855bba",
   "metadata": {},
   "source": [
    "删除文件："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "ef8584bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.remove('data.txt')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67117c81",
   "metadata": {},
   "source": [
    "## 函数\n",
    "\n",
    "使用括号对函数进行调用："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "d11ba6de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12.3"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "abs(-12.3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7ac28a0",
   "metadata": {},
   "source": [
    "用`def`定义函数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e4bf5251",
   "metadata": {},
   "outputs": [],
   "source": [
    "def poly(x, a, b, c):\n",
    "    y = a * x ** 2 + b * x + c\n",
    "    return y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "160c03e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = 1\n",
    "poly(x, 1, 2, 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b40018ba",
   "metadata": {},
   "source": [
    "用Numpy数组做参数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "23865b90",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 6, 11, 18])"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.array([1, 2, 3])\n",
    "poly(x, 1, 2, 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58c15b43",
   "metadata": {},
   "source": [
    "## 模块\n",
    "\n",
    "用`import`导入模块："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "db19be1f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b18c1ea8",
   "metadata": {},
   "source": [
    "当前系统分隔符："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "85ff6b43",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/'"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.sep"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a19cc58",
   "metadata": {},
   "source": [
    "## 类\n",
    "\n",
    "用class定义类："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "cbbc5f6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Person(object):\n",
    "    def __init__(self, first, last, age):\n",
    "        self.first = first\n",
    "        self.last = last\n",
    "        self.age = age\n",
    "    def full_name(self):\n",
    "        return self.first + ' ' + self.last"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "775a7391",
   "metadata": {},
   "source": [
    "构建对象："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "a0c6a894",
   "metadata": {},
   "outputs": [],
   "source": [
    "person = Person('Mertle', 'Sedgewick', 52)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb42c02f",
   "metadata": {},
   "source": [
    "调用对象的属性："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "1d43c644",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mertle'"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person.first"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c415161c",
   "metadata": {},
   "source": [
    "调用对象的方法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "694b903d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mertle Sedgewick'"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person.full_name()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9271b04c",
   "metadata": {},
   "source": [
    "## 错误处理\n",
    "\n",
    "输入错误的代码会提示报错："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04c1fe57",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
